package models.domain;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "Bill")
public class Bill {

	@Id
	@Column(name = "id")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	@Column
	private Date usageFrom;

	@Column
	private Date usageTo;

	@Column
	private Date issueDate;

	@Column
	private Date dueDate;

	@Column
	private float charge;

	@OneToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
	@JoinColumn(name = "paymentId", nullable = true)
	private Payment payment;

	@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
	@JoinColumn(name = "callsID")
	private List<Call> calls = new ArrayList<Call>();

	@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
	@JoinColumn(name = "SMSId")
	private List<SMS> Smss = new ArrayList<SMS>();

	@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
	@JoinColumn(name = "dataID")
	private List<Data> data = new ArrayList<Data>();

	public Bill() {
		super();
	}

	public Bill(Date usageFrom, Date usageTo, Date issueDate, Date dueDate,
			float charge, Payment payment, List<Call> calls, List<SMS> smss,
			List<Data> data) {
		super();
		this.usageFrom = usageFrom;
		this.usageTo = usageTo;
		this.issueDate = issueDate;
		this.dueDate = dueDate;
		this.charge = charge;
		this.payment = payment;
		this.calls = calls;
		Smss = smss;
		this.data = data;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getUsageFrom() {
		return usageFrom;
	}

	public void setUsageFrom(Date usageFrom) {
		this.usageFrom = usageFrom;
	}

	public Date getUsageTo() {
		return usageTo;
	}

	public void setUsageTo(Date usageTo) {
		this.usageTo = usageTo;
	}

	public Date getIssueDate() {
		return issueDate;
	}

	public void setIssueDate(Date issueDate) {
		this.issueDate = issueDate;
	}

	public Date getDueDate() {
		return dueDate;
	}

	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
	}

	public float getCharge() {
		return charge;
	}

	public void setCharge(float charge) {
		this.charge = charge;
	}

	public Payment getPayment() {
		return payment;
	}

	public void setPayment(Payment payment) {
		this.payment = payment;
	}

	public List<Call> getCalls() {
		return calls;
	}

	public void setCalls(List<Call> calls) {
		this.calls = calls;
	}

	public List<SMS> getSmss() {
		return Smss;
	}

	public void setSmss(List<SMS> smss) {
		Smss = smss;
	}

	public List<Data> getData() {
		return data;
	}

	public void setData(List<Data> data) {
		this.data = data;
	}

	public void addSMSLineItem(SMS sms) {
		Smss.add(sms);
	}

	public void addCallLineItem(Call call) {
		calls.add(call);
	}

	public void addDataLineItem(Data data) {
		this.data.add(data);
	}

}
